package com.youngjun.user.controller.admin;

import com.youngjun.common.mybatis.web.BaseController;
import com.youngjun.common.mybatis.web.Response;
import com.youngjun.user.api.admin.IDepartmentRestApi;
import com.youngjun.user.pojo.dto.DepartmentDTO;
import com.youngjun.user.pojo.dto.query.DepartmentQueryDTO;
import com.youngjun.user.pojo.vo.DepartmentVO;
import com.youngjun.user.service.DepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/department")
public class DepartmentController implements IDepartmentRestApi,BaseController {

    @Autowired
    DepartmentService departmentService;

    @Override
    public Response<List<DepartmentVO>> queryListByCurrentOrganization(@RequestBody DepartmentQueryDTO dto) {
        List<DepartmentVO> data = departmentService.queryListByCurrentOrganization(dto);
        return new Response<>(data);
    }

    @Override
    public Response<List<DepartmentVO>> queryList(@RequestBody DepartmentQueryDTO dto) {
        List<DepartmentVO> data = departmentService.queryList(dto);
        return new Response<>(data);
    }

    @Override
    public Response<DepartmentVO> createByCurrentOrganization(@RequestBody DepartmentDTO dto) {
        DepartmentVO data = departmentService.createByCurrentOrganization(dto);
        return new Response<>(data);
    }

    @Override
    public Response<DepartmentVO> create(@RequestBody DepartmentDTO dto) {
        DepartmentVO data = departmentService.create(dto);
        return new Response<>(data);
    }

    @Override
    public Response<DepartmentVO> modifyByCurrentOrganization(@RequestBody DepartmentDTO dto) {
        DepartmentVO data = departmentService.modifyByCurrentOrganization(dto);
        return new Response<>(data);
    }

    @Override
    public Response<DepartmentVO> modify(@RequestBody DepartmentDTO dto) {
        DepartmentVO data = departmentService.modify(dto);
        return new Response<>(data);
    }

    @Override
    public Response<Void> deleteByCurrentOrganization(@RequestParam("id") Long id){
        departmentService.deleteByCurrentOrganization(id);
        return new Response<>();
    }

    @Override
    public Response<Void> delete(@RequestParam("id") Long id){
        departmentService.delete(id);
        return new Response<>();
    }

}